package org.jeecg.modules.flow.callback.takestockplan;

import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.business.takestockplan.entity.TakeStockPlan;
import org.jeecg.modules.business.takestockplan.service.ITakeStockPlanService;
import org.jeecg.modules.flow.sys.common.BaseCustomBeanRun;
import org.jeecg.modules.flow.sys.entity.dto.BaseFlowDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/*
 * 项目名称:    wms-server-jeecg
 * 接口描述:    盘点任务保存
 * 创建人员:    lumingyi
 * 创建时间:    2023-09-28
 */
@Component
public class TakeStockPlanSaveBean<T> extends BaseCustomBeanRun<T> {

    @Autowired
    private ITakeStockPlanService takeStockPlanService;

    @Override
    public void actureRun() {
        BaseFlowDto baseFlowDto = this.getBaseFlowDto();
        baseFlowDto.translateClass(TakeStockPlan.class);
        TakeStockPlan takeStockPlan = (TakeStockPlan) baseFlowDto.getData();

        if (StringUtils.isBlank(takeStockPlan.getId())) {
            takeStockPlanService.save(takeStockPlan);
            baseFlowDto.setInfoId(takeStockPlan.getId());
        } else {
            takeStockPlanService.updateById(takeStockPlan);
        }
    }
}
